Fix Android Text clipping with Bold text setting#57118
Open
TorinAsakura wants to merge 3 commits into
Open
Conversation
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D108136049. |
javache
requested changes
Jun 11, 2026
| textEffectRegistry: TextEffectRegistry?, | ||
| ): Spannable { | ||
| var text: Spannable? | ||
| if (attributedString.contains(AS_KEY_CACHE_ID)) { |
Contributor
There was a problem hiding this comment.
The new fontWeightAdjustment parameter is only applied when creating a fresh spannable. When AS_KEY_CACHE_ID is present, the previously cached spannable is returned (lines 704-716) without revalidation — carrying stale CustomStyleSpan weights from before the Bold Text setting changed.
| } | ||
|
|
||
| @Test | ||
| fun `plain text paint applies Android font weight adjustment`() { |
Contributor
There was a problem hiding this comment.
The test only asserts paint.typeface is non-null. If applyFontWeightAdjustment returned any non-null typeface without applying the weight adjustment (e.g., always Typeface.DEFAULT at weight 400), the test would still pass while the production bug persisted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Fixes #54931.
Android's Bold text accessibility setting updates
Configuration.fontWeightAdjustment, which makes platformTextViewdraw text with an adjusted typeface. React Native was measuring Text without that adjustment, so Yoga could allocate a row item width that was too small and the rendered text was clipped.This passes the current font weight adjustment through Fabric text measurement, prepared text layout, mounted Text spans, and TextInput spans, and applies it to the
TextPaint/CustomStyleSpantypeface used for measurement and drawing.Changelog:
[ANDROID] [FIXED] - Account for Android Bold text font weight adjustment when measuring Text.
Test Plan:
./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests com.facebook.react.views.text.TextLayoutManagerFontWeightAdjustmentTest -Preact.internal.useHermesStable=true./gradlew :packages:react-native:ReactAndroid:ktfmtCheck -Preact.internal.useHermesStable=trueReproduced locally before the fix with https://github.com/Lego4m/reproducer-react-native-android-bold-text on Android 16 AVD by toggling
font_weight_adjustmentbetween0and300.Screenshots from #54931: